class ATM
{
    static constexpr int coin[5] = {20, 50, 100, 200, 500};
    vector<int> cnt;    // 每种面额的数量
    static constexpr int kinds = size(coin);
public:
    ATM()
    {
        cnt.resize(5, 0);
    }
    
    void deposit(vector<int> banknotesCount)
    {
        // 存钱
        for(int i = 0; i < kinds; i++)
            cnt[i] += banknotesCount[i];
    }
    
    vector<int> withdraw(int amount)
    {
        vector<int> ans(kinds);

        // 计算每种面额所需数量，从大到小取
        for(int i = kinds - 1; i >= 0; i--)
        {
            ans[i] = min(amount / coin[i], cnt[i]);
            amount -= ans[i] * coin[i];
        }

        // 无法正常取完
        if(amount > 0)
            return {-1};
        
        // 更新
        for(int i = 0; i < kinds; i++)
            cnt[i] -= ans[i];
        return ans;
    }
};

/**
 * Your ATM object will be instantiated and called as such:
 * ATM* obj = new ATM();
 * obj->deposit(banknotesCount);
 * vector<int> param_2 = obj->withdraw(amount);
 */